/*
 * WT61.h
 *
 *  Created on: May 27, 2024
 *      Author: LUCKBACK
 */

#ifndef __WT61_H__
#define __WT61_H__

#include "usart.h"

#define WT61_SERIAL_HANDLE &huart1

#define WRITE_HEAD_H 0xFF
#define WRITE_HEAD_L 0xAA

#define READ_HEAD 			0x55
#define READ_TYPE_ACC 		0x51
#define READ_TYPE_GYRO 		0X52
#define READ_TYPE_ANGLE 	0x53

#define CLEAR_Z_ANGLE 			0x52
#define ACC_CALIBRATION 		0x67
#define HIBERNATION 			0x60
#define SERIAL_MODE				0x61
#define I2C_MODE				0x62
#define BAUDRATE_115200			0x63
#define BAUDRATE_9600			0x64
#define HORIZONTAL_INSTALLATION 0x65
#define VERTICAL_INSTALLATION	0x66

struct SAcc
{
	float a[3];
	float T;	// 温度
};
struct SGyro
{
	float w[3];
	float Vol;	// 电压(非蓝牙产品，该数据无效)
};
struct SAngle
{
	float Angle[3];
	short Version;	// 版本
};

extern struct SAcc 		stcAcc;
extern struct SGyro 	stcGyro;
extern struct SAngle 	stcAngle;

void WT61_Init(void);
void WT61_Hibernation(void);
void WT61_ModeType(uint8_t mode);
void WT61_SetBaudrate(uint32_t baudrate);
void WT61_Install(uint8_t position);
void CopeSerialData(unsigned char ucData);
void WT61_ReadData(void);
float getGyroZ();
extern uint8_t GYRO_data;

#endif /* INC_WT61_H_ */
